import java.util.Arrays;

public class NM1 {
    //快速排序之挖空法；
    public static void quick(int[] array){
        quickSort(array,0,array.length-1);
    }
    public static void quickSort(int[] array,int start,int end){
        if(start>=end){
            return;
        }
        int point1=partition(array,start,end);
        quickSort(array,start,point1-1);
        quickSort(array,point1+1,end);
    }
    public static int  partition(int[] array,int left,int right){
        int tmp=array[left];
        while(left<right){
            while(left<right&&array[right]>=tmp){
                right--;
            }
            array[left]=array[right];
            while(left<right&&array[left]<=tmp){
                left++;
            }
            array[right]=array[left];
        }
        array[left]=tmp;
        return left;
    }
    public static void swap(int[] array,int i,int j){
        int tmp=array[i];
        array[i]=array[j];
        array[j]=tmp;
    }
    public static void main(String[] args){
        int[] array={6,1,2,7,9,3,4,5,10,8};
        quick(array);
        System.out.println(Arrays.toString(array));
    }
}
